| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 79 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| Bugs | 0 | Features | 1 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /**  | 
            ||
| 5 |   Cart: new function () { | 
            ||
| 6 |     this.addItem = function (itemOfferPriceId, count, btn, callback) { | 
            ||
| 7 |       inji.Server.request({ | 
            ||
| 8 | url: 'ecommerce/cart/add',  | 
            ||
| 9 |         data: { | 
            ||
| 10 | itemOfferPriceId: itemOfferPriceId,  | 
            ||
| 11 | count: count  | 
            ||
| 12 | },  | 
            ||
| 13 |         success: function (data) { | 
            ||
| 14 |           if (callback) { | 
            ||
| 15 | callback(data, btn);  | 
            ||
| 16 | }  | 
            ||
| 17 |           inji.Server.request({ | 
            ||
| 18 | url: 'ecommerce/cart/getCart',  | 
            ||
| 19 |             success: function (data) { | 
            ||
| 20 |               $("#cart,.cartplace").html(data); | 
            ||
| 21 | }  | 
            ||
| 22 | });  | 
            ||
| 23 | }  | 
            ||
| 24 | }, btn);  | 
            ||
| 25 | };  | 
            ||
| 26 |     this.calcSum = function (form) { | 
            ||
| 27 |       if (form === undefined) { | 
            ||
| 28 |         form = $('.ecommerce .cart-order_page form'); | 
            ||
| 29 | }  | 
            ||
| 30 |       else { | 
            ||
| 31 | form = $(form)  | 
            ||
| 32 | }  | 
            ||
| 33 | var formData = new FormData(form[0]);  | 
            ||
| 34 |       $('.ecommerce .cart-order_page').prepend($('<div style = "position:absolute;width:' + $('.ecommerce .cart-order_page').width() + 'px;height:' + $('.ecommerce .cart-order_page').height() + 'px;background-color: rgba(255, 255, 255, 0.4);z-index:1000000"></div>')); | 
            ||
| 35 |       inji.Server.request({ | 
            ||
| 36 |         url: form.attr('action'), | 
            ||
| 37 | type: 'POST',  | 
            ||
| 38 | data: formData,  | 
            ||
| 39 | dataType: 'html',  | 
            ||
| 40 | processData: false,  | 
            ||
| 41 |         success: function (data) { | 
            ||
| 42 |           $('.ecommerce .cart-order_page').html($(data).find('.ecommerce .cart-order_page').html()); | 
            ||
| 43 |           if ($(data).find('.alert').length > 0) { | 
            ||
| 44 |             $.each($(data).find('.alert'), function () { | 
            ||
| 45 |               //$('.ecommerce .cart-order_page').prepend(this.outerHTML) | 
            ||
| 46 | })  | 
            ||
| 47 | }  | 
            ||
| 48 | }  | 
            ||
| 49 | });  | 
            ||
| 50 | };  | 
            ||
| 51 |     this.delItem = function (cart_item_id) { | 
            ||
| 52 |       var form = $('.ecommerce .cart-order_page form'); | 
            ||
| 53 |       $('.cart_item_id' + cart_item_id).remove(); | 
            ||
| 54 | var formData = new FormData(form[0]);  | 
            ||
| 55 |       $('.ecommerce .cart-order_page').prepend($('<div style = "position:absolute;width:' + $('.ecommerce .cart-order_page').width() + 'px;height:' + $('.ecommerce .cart-order_page').height() + 'px;background-color: rgba(255, 255, 255, 0.4);z-index:1000000"></div>')); | 
            ||
| 56 |       inji.Server.request({ | 
            ||
| 57 |         url: form.attr('action'), | 
            ||
| 58 | type: 'POST',  | 
            ||
| 59 | data: formData,  | 
            ||
| 60 | dataType: 'html',  | 
            ||
| 61 | processData: false,  | 
            ||
| 62 |         success: function (data) { | 
            ||
| 63 |           $('.ecommerce .cart-order_page').html($(data).find('.ecommerce .cart-order_page').html()); | 
            ||
| 64 |           if ($(data).find('.alert').length > 0) { | 
            ||
| 65 |             $.each($(data).find('.alert'), function () { | 
            ||
| 66 |               //$('.ecommerce .cart-order_page').prepend(this.outerHTML) | 
            ||
| 67 | })  | 
            ||
| 68 | }  | 
            ||
| 69 | }  | 
            ||
| 70 | });  | 
            ||
| 71 | };  | 
            ||
| 72 |     this.delItemWidget = function (cart_item_id, callback) { | 
            ||
| 73 |       inji.Server.request({ | 
            ||
| 74 | url: '/ecommerce/cart/deleteItem?cartItemId=' + cart_item_id,  | 
            ||
| 75 |         success: function (data) { | 
            ||
| 76 |           $("#cart,.cartplace").html(data); | 
            ||
| 77 |           if (callback !== undefined) { | 
            ||
| 78 | callback();  | 
            ||
| 79 | }  | 
            ||
| 80 | }  | 
            ||
| 81 | });  | 
            ||
| 82 | }  | 
            ||
| 83 | },  | 
            ||
| 84 |   toggleFav: function (itemId, btn, noChangeText) { | 
            ||
| 176 |